package com.wenhao.interview.pinduoduo;

import java.util.*;

/**
 * @author Wenhao Tong
 * @create 2021-07-25 19:11
 */
public class Main2 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int[] chicken = new int[N];
        int[] duck = new int[N];
        for (int i = 0;i < N;i++) {
            chicken[i] = scanner.nextInt();
        }
        for (int i = 0;i < N;i++) {
            duck[i] = scanner.nextInt();
        }
        Set<Integer> poker = new HashSet<>();
        LinkedList<Integer> line = new LinkedList<>();
        int c = 0,d = 0;
        int cwin = 0,dwin = 0;
        while (c < N || d < N) {
            while (c < N && poker.contains(chicken[c])) {
                cwin++;
                while (line.peek() != chicken[c]) {
                    poker.remove(line.pop());
                    cwin++;
                }
                poker.remove(line.pop());
                cwin++;
                c++;
            }
            if (c < N) {
                poker.add(chicken[c]);
                line.push(chicken[c]);
            }
            c++;
            while (d < N && poker.contains(duck[d])) {
                dwin++;
                while (line.peek() != duck[d]) {
                    poker.remove(line.pop());
                    dwin++;
                }
                poker.remove(line.pop());
                dwin++;
                d++;
            }
            if (d < N) {
                poker.add(duck[d]);
                line.push(duck[d]);
            }
            d++;
        }
        while (line.size() > 0) {
            if (line.pop() % 2 == 0) {
                dwin++;
            } else {
                cwin++;
            }
        }
        System.out.println(cwin + " " + dwin);
    }
}
